package TEST;
import java.util.Arrays;

public class Test05 {

        private int id;
        private String name;
        private int score;
        public Test05(int id, String name, int score) {
            super();
            this.id = id;
            this.name = name;
            this.score = score;
        }

        public int getId() {
            return id;
        }

        public void setId(int id) {
            this.id = id;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public int getScore() {
            return score;
        }

        public void setScore(int score) {
            this.score = score;
        }

        @Override
        public String toString() {
            return (id + "   " + name + "   " + score);
        }

    }





    public class TestStudent {
        static Test05[] stus;
        public static void sort(Test05[] stus){
            int len = stus.length;
            int[] a = new int[len];

            for (int i = 0; i < len; i++) {
                a[i] = stus[i].getScore();
            }

            Arrays.sort(a);

            for (int i = a.length - 1; i >= 0 ; i--) {
                for (int j = 0; j < stus.length; j++) {
                    if(stus[j].getScore() == a[i]){
                        System.out.println(stus[j]);
                    }
                }
            }
        }
        public static void main(String[] args) {
            stus = new Test05[3];
            stus[0] = new Test05(1,"a",87);
            stus[1] = new Test05(2,"b",78);
            stus[2] = new Test05(3,"c",99);
            System.out.println("按分数从高到低排序：");
            sort(stus);
        }
    }

